*** Settings ***
Library    RequestsLibrary
Library    JSONLibrary
Library    String
#Variables  ../work_env.py
Name       用户使用手机验证码登录

*** Test Cases ***
用户使用手机验证码成功登录
    #设置请求头
    ${headers}   Create Dictionary    Content-Type=application/json
# 从字典配置获取当前测试根路径   Create Session    testing-base-url    ${env_vars}[base_url]
    Create Session    testing-base-url    ${ENV_BASE_URL}
    ${json}    Set Variable    {"mobilePhoneNo": "15328990000","captchaCode": "123456"}
    #发送post请求，并用变量接收响应结果
    ${resp}    POST On Session    testing-base-url    user/login/by-mobile-phone    data=${json}   headers=${headers}
    Log    ${resp.status_code}
    #获取本次的响应数据
    Log    ${resp.text}
    #断言返回结果
    Should Be Equal     ${resp.text}     登录成功
用户使用错误验证码登录
    #设置请求头
    ${headers}   Create Dictionary    Content-Type=application/json
# 从字典配置获取当前测试根路径    Create Session    testing-base-url     ${env_vars}[base_url]
    Create Session    testing-base-url    ${ENV_BASE_URL}
    ${json}    Set Variable    {"mobilePhoneNo": "18688710213","captchaCode": "1232"}
    #发送post请求，并用变量接收响应结果
    ${resp}    POST On Session    testing-base-url    user/login/by-mobile-phone    data=${json}   headers=${headers}
    Log    ${resp.status_code}
    #获取本次的响应数据
    Log    ${resp.json()}
    #断言返回结果
    Should Be Equal     ${resp.json()[0]}     验证码错误
